package com.yangle.frame.bizlogic.service;

import com.yangle.frame.bizlogic.entity.Tages;
import com.yangle.frame.bizlogic.mapper.TagesMapper;
import com.yangle.frame.common.service.BaseService;
import com.yangle.frame.common.utils.MapperUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Arrays;
import java.util.List;

/**
* Created by yangle on 2018/5/27.
*/
@Service
public class TagesService implements BaseService<Tages> {
@Autowired
private TagesMapper tagesMapper;

public List<Tages> getAll(Tages tages) {
Example example = MapperUtils.getExampleByClass(Tages.class, tages);
return tagesMapper.selectByExample(example);
}

public void create(Tages tages) {
tagesMapper.insert(tages);
}

public void update(Tages tages) {
tagesMapper.updateByPrimaryKey(tages);
}

public Tages select(String id) {
return tagesMapper.selectByPrimaryKey(id);
}

public void delete(String ids) {
tagesMapper.deletes(Arrays.asList(ids.split(",")));
}

    /**
     * 按照文章ID删除
     */
    public void deleteByArticleId(String articleId){
        Tages tages=new Tages();
        tages.setArticleID(articleId);
        tagesMapper.delete(tages);
    }
}
